package org.orr.budgetpro.entities;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@Entity
public class Budget implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue
	Integer budgetId;

	@OneToOne
	private User user;

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "budget")
	@Cascade(value = CascadeType.ALL)
	@Valid
	private List<IncomeItem> incomeItems;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "budget")
	@Cascade(value = CascadeType.ALL)
	@Valid
	private List<ExpenseItem> expenseItems;

	public Budget() {
		super();
	}

	public Budget(Integer budgetId) {
		super();
		this.budgetId = budgetId;
	}

	public Integer getBudgetId() {
		return budgetId;
	}

	public void setBudgetId(Integer budgetId) {
		this.budgetId = budgetId;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public List<IncomeItem> getIncomeItems() {
		return incomeItems;
	}

	public void setIncomeItems(List<IncomeItem> incomeItems) {
		this.incomeItems = incomeItems;
	}

	public List<ExpenseItem> getExpenseItems() {
		return expenseItems;
	}

	public void setExpenseItems(List<ExpenseItem> expenseItems) {
		this.expenseItems = expenseItems;
	}

}
